package com.toe.pojo.entity.user;

import com.baomidou.mybatisplus.annotation.IdType;

import java.time.LocalDateTime;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;

/**
 * <p>
 * 权限表
 * </p>
 *
 * @author 陶涛
 * @since 2022-07-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="UserPermission对象", description="权限表")
public class UserPermission implements Serializable, GrantedAuthority {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "权限名称")
    private String permissionName;

    @ApiModelProperty(value = "权限值")
    private String permissionValue;

    @ApiModelProperty(value = "权限描述")
    private String description;

    @ApiModelProperty(value = "自定义排序序号")
    private Integer sort;

    @ApiModelProperty(value = "数据创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "数据最后修改时间")
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;


    public void setPermissionValue(String permissionValue){
        this.permissionValue = permissionValue;
    }

    @Override
    public String getAuthority() {
        return permissionValue;
    }
}
